// vim: foldmethod=marker : foldmarker=<<<,>>>
/*
 File: signal.h
 Product: <product>
 Creating date: 06/12/2006 22:43
 Remark: 
*/
#ifndef branch_signalH
#define branch_signalH

#define GO__branch(cond,tag) GO(cond,tag)
#define GO(cond,tag) \
 do { if (branch_COND__##cond) goto tag; } while(0)

//#define WRECK(tag) ???

#define SIGNAL(cond,cause,tag) \
 do {\
  if (branch_COND__##cond) { \
   branch_CAUSE__##cause; \
   branch_TAG__##tag; \
   }\
  } while(0)

#define branch_CAUSE__
#define branch_CAUSE__none

#define branch_CAUSE__thisStatus(__status) this->status=__status
#define branch_CAUSE__thisCause(__cause) \
 TEST__audit(ifNull(this->cause)); \
 this->cause=__cause

#define branch_CAUSE__wayLastError(__error) \
 HITCH__faultWay(createWith__fault_lastError(__error))

#define branch_CAUSE__hrCode(code) hr=code;
#define branch_CAUSE__hrWin(win32) hr=HRESULT_FROM_WIN32(win32)

#define branch_TAG__go(tag) goto tag

#define branch_TAG__f(index) goto fail##index
#define branch_TAG__fail0 goto fail0
#define branch_TAG__fail1 goto fail1
#define branch_TAG__fail2 goto fail2
#define branch_TAG__fail3 goto fail3
#define branch_TAG__fail4 goto fail4

#define branch_TAG__e(index) goto exit##index
#define branch_TAG__exit0 goto exit0
#define branch_TAG__exit1 goto exit1
#define branch_TAG__exit2 goto exit2

#define branch_TAG__g(index) goto gain##index
#define branch_TAG__gain0 goto gain0
#define branch_TAG__gain1 goto gain1

#define branch_TAG__r(value) return value
#define branch_TAG__ret0 return 0;

#define branch_TAG__w(protector) wreck__fault_protector(protector)
#define branch_TAG__wreck wreck__fault_protector(getProtector__faultWay())
#define branch_TAG__wreck0 wreck__fault_protector(__protector)
#define branch_TAG__wayWreck wreck__fault_protector(getProtector__faultWay())

#endif

